<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import="org.apache.commons.beanutils.locale.*" %>
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet"  href="<%=request.getContextPath()%>/css/display.css" type="text/css" media="screen" />
<script src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script src="<%=request.getContextPath()%>/js/autocomplete.js"></script>
<script src="<%=request.getContextPath()%>/js/form.js"></script> 
<script type="text/javascript" src='<%=request.getContextPath()%>/js/input01.js'></script>
<% facades.SessionFacade sfacade = (facades.SessionFacade)request.getAttribute("sfacade"); %>
<title>Gestione Auser - Accompagnatori</title>

</head>
<body> 
	 
	 <form method="post" action="save.jsp" name="formData" id=""formData"">
		 <c:if test="${empty param.id}" >
		 	<h1>Aggiunta di un Accompagnatore</h1>   
		 	<input type="hidden" name="EditMode" value="ADD" />
		 </c:if>
		 
		 <c:if test="${!empty param.id}" >
		 	<h1>Dati Accompagnatore</h1> 
		 	<input type="hidden" name="EditMode" value="EDIT" />
		 </c:if>
		 
		 
		<fieldset>
			<legend>Dati principali</legend>  
	
	 		<label for='cognome'>Cognome</label><input type="text" name="cognome" id="cognome" size="45" value="${editAcctore.cognome}" /> 
	 		<label class='validError'>${eCognome}</label><br/>
	 		<label for='nome'>Nome</label><input type="text" name="nome" id="nome"  size="45" value="${editAcctore.nome}" />
	 		<label class='validError'>${eNome}</label> <br/> 
	 		
	 		<label for='indirizzo'>Indirizzo</label><input type="text" name="indirizzo" id="indirizzo"  size="45" value="${editAcctore.indirizzo}" /><br/>
	 		<label for='comune'>Città</label><input type="text" name="comune" id="comune"  size="45" value="${editAcctore.comune}" /><br/>
	 		<div class='howtomsg'>Dopo aver digitato i primi tre caratteri compare la lista dei comuni</div><br>
	 		<label for='cap'>Cap</label><input type="text" name="cap" id="cap"  size="6" value="${editAcctore.cap}" />
	 		<label for='provincia'>Provincia</label><input type="text" name="provincia" id="provincia"  size="5" value="${editAcctore.provincia}" /><br/>
	 		 
			<label for='telefono'>Telefono</label><input type="text" name="telefono" id="telefono" size="45" value="${editAcctore.telefono}" /><br>
			  
				
		</fieldset>	
 		
 		<fieldset>
			<legend>Mezzo proprio</legend>
			
			<label for='descrizione'>Descrizione</label><input type="text" name="mezzoProprio.descrizione" id="mezzoProprio.descrizione" size="45" value="${editAcctore.mezzoProprio.descrizione}" /> 
	 		<label class='validError'>${eDescrizione}</label><br/>
	 		
	 		<label for='targa'>Targa</label><input type="text" name="mezzoProprio.targa" id="mezzoProprio.targa" size="45" value="${editAcctore.mezzoProprio.targa}" /> 
	 		<label class='validError'>${eTarga}</label><br/>
	 		
	 		<label for='posti'>Posti</label><input type="Integer" type="text" name="mezzoProprio.posti" id="mezzoProprio.posti" size="5" value="${editAcctore.mezzoProprio.posti}" /> <br/>
	 		<label for='assicurazione'>Assicurazione</label><input type="text" name="mezzoProprio.assicurazione" id="mezzoProprio.assicurazione" size="45" value="${editAcctore.mezzoProprio.assicurazione}" /> <br/>
	 		<label for='modello'>modello</label>
	 			<select name="mezzoProprio.modello" id="mezzoProprio.modello">
	 				<option value="">
	 				<option value="berlina" ${editAcctore.mezzoProprio.modello=="berlina"?"selected":""}>Berlina
	 				<option value="station" ${editAcctore.mezzoProprio.modello=="station"?"selected":""}>Station Wagon
	 			</select> <br><br>
	 			
	 		<b>Condizioni convenute per rimborsi</b>
	 		<hr size="1">	
	 		<label for='rimborsoKm'>Rimborso Km € </label><input class="Float" type="text" name="mezzoProprio.rimborsoKm" id="mezzoProprio.rimborsoKm"  size="5" value="<fmt:formatNumber pattern="0.00" value="${editAcctore.mezzoProprio.rimborsoKm}"  />"  /> 
	 		<label class='validError'>${eRimborsoKm}</label> <br/> 
	 		
	 			
	 			
		</fieldset>	
	
		<fieldset>
			<legend>Disponibilità</legend>
			
			<input type="checkbox" id="lunedi" name="lunedi" ${editAcctore.lunedi?"checked":""} /> Lunedi<br/>
			<input type="checkbox" id="martedi" name="martedi" ${editAcctore.martedi?"checked":""} /> Martedi<br/>
			<input type="checkbox" id="mercoledi" name="mercoledi" ${editAcctore.mercoledi?"checked":""} /> Mercoledi<br/>
			<input type="checkbox" id="giovedi" name="giovedi" ${editAcctore.giovedi?"checked":""} /> Giovedi<br/>
			<input type="checkbox" id="venerdi" name="venerdi" ${editAcctore.venerdi?"checked":""} /> Venerdi<br/>
			<input type="checkbox" id="sabato" name="sabato" ${editAcctore.sabato?"checked":""} /> Sabato<br/>
			<input type="checkbox" id="domenica" name="domenica" ${editAcctore.domenica?"checked":""} /> Domenica<br/>
			
	 		<label>Dalle Ore : </label> 
			
				<select id="hDalle" name="HDalle" style="margin-right:0px">
					<c:forEach begin="0" end="24" varStatus="st">   
						<option value="${st.index}"  ${editAcctore.HDalle==st.index?"selected":""} >${st.index<10?'0':''}${st.index}</option>
					</c:forEach>	 
				</select>
				
				<select id="mDalle" name="MDalle" style="margin-left:0px">
				 	<c:forEach begin="0" end="55" step="5" varStatus="st">   
						<option value="${st.index}"  ${editAcctore.MDalle==st.index?"selected":""} >${st.index<10?'0':''}${st.index}</option>
					</c:forEach>
				</select> <br>
				
				<label>Alle Ore : </label> 
			
				<select id="HAlle" name="HAlle" style="margin-right:0px">
					<c:forEach begin="0" end="24" varStatus="st">   
						<option value="${st.index}" ${editAcctore.HAlle==st.index?'selected':''}>${st.index<10?'0':''}${st.index}</option>
					</c:forEach>	 
				</select>
				
				<select id="MAlle" name="MAlle" style="margin-left:0px">
				 	<c:forEach begin="0" end="55" step="5" varStatus="st">   
						<option value="${st.index}" ${editAcctore.MAlle==st.index?"selected":""}>${st.index<10?'0':''}${st.index}</option>
					</c:forEach>
				</select>
			
			
			 	<br>
		
			<input style='float:right' class='button' type='button' value='Esci senza salvare' id='btnClose' onclick='document.location="<%=request.getContextPath()%>/app/start/index.jsp"'> 
	 		<input style='float:right' class='button' type='submit' value='Salva' id='btnSave' />
	 		
		</fieldset>	
		
		<script>
			function formatItem(row) {
				return "<b>" + row[0]+"</b> (" + row[2] + ")";
			}
			
			function selectItemComune(li) {  
				if (li.extra) {
					$("#cap").val(li.extra[0]); 
					$("#provincia").val(li.extra[1]); 
					$("telefono").focus();
				}	
			}
			$(function(){	 
				$("#comune").autocomplete("<%=request.getContextPath()%>/app/comuni/lookup.jsp", { minChars:3,  matchContains:1, cacheLength:30, onItemSelect:selectItemComune, formatItem:formatItem, selectOnly:1 });
			 
			});
		</script>
</body>
</html>